package com.atguigu.mycloud.Enum;

import lombok.Getter;

/**
 * @author 任浩
 * @version 1.0
 */

@Getter
public enum ReturnCodeEnum {
    RC101("101","请求资源错误"),
    RC200("200","请求成功"),
    RC400("400","请求路径的语法错误"),
    RC401("401","请求没有访问权限"),
    RC403("403","服务器端接收到请求，但拒绝执行"),
    RC500("500","服务器内部资源错误");

    //构造
    private String code;
    private String message;

    ReturnCodeEnum(String code,String message){
        this.code = code;
        this.message = message;
    }

    //进行遍历
    // 通过码值得到对应的错误信息。
    public static ReturnCodeEnum getReturnCodeEnumValue(String code){
        for (ReturnCodeEnum value : ReturnCodeEnum.values()) {
            if(value.getCode().equals(code)){
                //匹配正确，返回值
                return value;
            }
        }
        return null;
    }
}
